home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Strings / ConstPString.h < prev    next >
Text File  |  1997-06-28  |  1KB  |  51 lines

  1. // ConstPString.h
  2.  
  3. #ifndef ConstPString_h
  4. #define ConstPString_h
  5.  
  6. #ifndef ConstData_h
  7. #include "ConstData.h"
  8. #endif
  9.  
  10. class ConstPString
  11.   {
  12.     private:
  13.         ConstStr255Param string;
  14.     
  15.         operator=( const ConstPString& );    // This method intentionally left undefined.
  16.             
  17.     public:
  18.         ConstPString( ConstStr255Param s )
  19.           : string( s )
  20.           {
  21.             Assert( s != 0 );
  22.           }
  23.  
  24.         uint8 Length() const                                { return string[0]; }
  25.         URange32 Range() const                            { return URange32( 0, Length() ); }
  26.         
  27.         const uint8& operator[]( uint32 i ) const
  28.             { Assert( i < Length() ); return string[i+1]; }
  29.         
  30.         ConstData Text() const                            { return ConstData( string+1, Length() ); }
  31.         ConstData Head( uint32 size ) const            { return Text().Head( size ); }
  32.         ConstData Tail( uint32 position ) const    { return Text().Tail( position ); }
  33.         ConstData Middle( URange32 range ) const    { return Text().Middle( range ); }
  34.  
  35.         operator ConstStr255Param() const            { return string; }
  36.         operator ConstData() const                        { return Text(); }
  37.   };
  38.  
  39.  
  40. bool operator==( ConstPString a, ConstPString b );
  41. bool operator< ( ConstPString a, ConstPString b );
  42. bool operator<=( ConstPString a, ConstPString b );
  43.  
  44. inline bool operator!=( ConstPString a, ConstPString b )        { return !(a == b); }
  45. inline bool operator> ( ConstPString a, ConstPString b )        { return !(a <= b); }
  46. inline bool operator>=( ConstPString a, ConstPString b )        { return !(a < b); }
  47.  
  48. int32 Compare( ConstPString a, ConstPString b );
  49.  
  50. #endif
  51.